//----------求和方式-----------------------------------------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;

int n, s;
vector<int>arr;
string store; 
unordered_map<string,int>mm;
bool vis[1000] = { false };
int ret = 0;

bool check( string str) {
	sort(str.begin(), str.end());

	if (mm[str] == 0) {
		mm[str]++;
		return false; 
	}
	return true; 
}

void dfs(int sum) {
	if (sum == s) {
		if(check(store)==false)ret++;
		return;
	}
	if (sum > s)return;

	for (int i = 0; i < n; i++) {
		if (!vis[i]) {
			vis[i] = true; 
			store += '0' +i; 
			dfs(sum+arr[i]);
			store.pop_back();
			vis[i] = false; 
		}
	}
}


int main() {
	cin >> n >> s;
	arr.resize(n);
	for (int i = 0; i < n; i++)cin >> arr[i];
	dfs(0);
	cout << ret << endl; 
	return 0;
}